package com.dragon.repository.domain.vo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.dragon.common.model.Update;
import com.dragon.repository.entity.OtherFile;
import com.dragon.repository.entity.Reimbursement;
import com.dragon.repository.entity.WorkflowJson;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import com.dragon.common.util.BeanUtils;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Date;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class ReimbursementVO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "报销名称")
    private String reimbursementName;

    @ApiModelProperty(value = "用户id")
    private Integer adminId;

    @ApiModelProperty(value = "部门id")
    private Integer departmentId;

    @ApiModelProperty(value = "审核状态：0待审核 1审核通过 2审核不通过 3作废 4删除")
    private Integer status;

    @ApiModelProperty(value = "备注")
    private String remark;

    @ApiModelProperty(value = "报销时间")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date reimbursementTime;

    @ApiModelProperty(value = "报销金额")
    private BigDecimal reimburseMoney;

    @ApiModelProperty(value = "银行账号")
    private String bankAccount;

    @ApiModelProperty(value = "开户行名称")
    private String bankName;

    @ApiModelProperty(value = "工作流json")
    private List<WorkflowJson> workflowJsonList;

    @ApiModelProperty(value = "附件")
    private List<OtherFile> otherFiles;

    @ApiModelProperty(value = "创建时间（申请时间）")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    @ApiModelProperty(value = "免审操作：0，不免审，1免审")
    private Integer exempt;

    @ApiModelProperty(value = "单据类型")
    private Integer reimburseType;

    @ApiModelProperty(value = "单据名称")
    private String expensesName;

    @ApiModelProperty(value = "付款状态：0未付款 1已付款" )
    private Integer paymentStatus;

    @ApiModelProperty(value = "付款账号")
    private String payAccount;

    @ApiModelProperty(value = "付款时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date payTime;

    @ApiModelProperty(value = "付款类型")
    private Integer payType;


    @NotNull(groups = Update.class,message = "主键不能为空")
    public static Reimbursement convert(ReimbursementVO vo) {
        Reimbursement entity = new Reimbursement();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<Reimbursement> convertList(List<ReimbursementVO> list) {
        List<Reimbursement> resultList = new ArrayList<>();
        for (ReimbursementVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
